<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>默认页面</title>
</head>
<body>

<div id="root">
    <school></school>
    </hr>
    <student></student>
</div>


</body>

<script src="../script/vue.js"></script>

<script>
    Vue.config.devtools = true;
    const school = Vue.extend({
        name: 'school',
        template: '<div>' +
                        '<h2>学校</h2>' +
                        '<h3>学校名称：{{schoolName}}</h3>' +
                        '<h3>学校地址：{{schoolAddress}}</h3> ' +
                        '<button @click="alterWay">提示学校名称</button> ' +
                    '</div>',
        data() {
            return {
                schoolName: '北京大学',
                schoolAddress: '北京'
            }
        },
        methods: {
            alterWay() {
                console.log(this.schoolName);
            }
        }
    });
    const student = Vue.extend({
        name: 'school',
        template: '<div>' +
                        '<h2>学生</h2>' +
                        '<h3>学生名称：{{studentName}}</h3>' +
                        '<h3>学生年龄：{{studentAge}}</h3>' +
                  '</div>',
        data() {
            return {
                studentName: '张三',
                studentAge: '18'
            }
        }
    });
    let vue = new Vue({
        el: '#root',
        components: {
            school,
            student,
        }
    })
</script>
</html>
